home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / tex-k / tex-k-archive.past / tex-k-archive.gz / tex-k-archive / 000654_v016193@otis1.stortek.com_Wed Jun 15 01:21:18 1994.msg < prev    next >
Internet Message Format  |  1994-10-11  |  11KB

  1. Received: from stortek.com by cs.umb.edu with SMTP id AA29827
  2.   (5.65c/IDA-1.4.4 for <tex-k@cs.umb.edu>); Wed, 15 Jun 1994 09:21:50 -0400
  3. Received: from otis1.stortek.com by stortek.com with SMTP id AA07975
  4.   (5.65c/IDA-1.4.4 for <tex-k@cs.umb.edu>); Wed, 15 Jun 1994 07:21:35 -0600
  5. From: John Tytus <v016193@otis1.stortek.com>
  6. X-Mailer: SCO System V Mail (version 3.2)
  7. To: tex-k@cs.umb.edu
  8. Date: Wed, 15 Jun 94 7:21:18 MDT
  9. Message-Id:  <9406150721.aa05266@otis1.stortek.com>
  10.  
  11. Original file:
  12. ftp.shsu.edu:/tex-archive/systems/web2c/web2c-6.1.tar.gz
  13.  
  14. Here are the code lines you asked about. the two lines called out by the
  15. conflict message are marked by the word CLASH.
  16. The compiler message:
  17. getopt.c: In function `getopt':
  18. getopt.c:672: argument `argv' doesn't match prototype
  19. getopt.h:104: prototype declaration
  20.  
  21.                                  John Tytus
  22.  
  23. /* THE GETOPT.H LINES */
  24.  
  25. #if __STDC__
  26. #if defined(__GNU_LIBRARY__)
  27. /* Many other libraries have conflicting prototypes for getopt, with
  28.    differences in the consts, in stdlib.h.  To avoid compilation
  29.    errors, only prototype getopt for the GNU C library.  */
  30. extern int getopt (int argc, char *const *argv, const char *shortopts);
  31. #else /* not __GNU_LIBRARY__ */
  32. extern int getopt (); /* CLASH */
  33. #endif /* not __GNU_LIBRARY__ */
  34.  
  35.  
  36. /* THE GETOPT.C LINES */
  37.  
  38.  
  39. #include <stdio.h>
  40.  
  41. /* Comment out all this code if we are using the GNU C Library, and are not
  42.    actually compiling the library itself.  This code is part of the GNU C
  43.    Library, but also included in many other GNU distributions.  Compiling
  44.    and linking in this code is a waste when using the GNU C library
  45.    (especially if it is a shared library).  Rather than having every GNU
  46.    program understand `configure --with-gnu-libc' and omit the object files,
  47.    it is simpler to just do this in the source for each such file.  */
  48.  
  49. #if defined (_LIBC) || !defined (__GNU_LIBRARY__)
  50.  
  51.  
  52. /* This needs to come after some library #include
  53.    to get __GNU_LIBRARY__ defined.  */
  54. #ifdef    __GNU_LIBRARY__
  55. /* Don't include stdlib.h for non-GNU C libraries because some of them
  56.    contain conflicting prototypes for getopt.  */
  57. #include <stdlib.h>
  58. #endif    /* GNU C library.  */
  59.  
  60. /* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
  61.    long-named option.  Because this is not POSIX.2 compliant, it is
  62.    being phased out.  */
  63. /* #define GETOPT_COMPAT */
  64.  
  65. /* This version of `getopt' appears to the caller like standard Unix `getopt'
  66.    but it behaves differently for the user, since it allows the user
  67.    to intersperse the options with the other arguments.
  68.  
  69.    As `getopt' works, it permutes the elements of ARGV so that,
  70.    when it is done, all the options precede everything else.  Thus
  71.    all application programs are extended to handle flexible argument order.
  72.  
  73.    Setting the environment variable POSIXLY_CORRECT disables permutation.
  74.    Then the behavior is completely standard.
  75.  
  76.    GNU application programs can use a third alternative mode in which
  77.    they can distinguish the relative order of options and other arguments.  */
  78.  
  79. #include "getopt.h"
  80.  
  81. /* For communication from `getopt' to the caller.
  82.    When `getopt' finds an option that takes an argument,
  83.    the argument value is returned here.
  84.    Also, when `ordering' is RETURN_IN_ORDER,
  85.    each non-option ARGV-element is returned here.  */
  86.  
  87. char *optarg = 0;
  88.  
  89. /* Index in ARGV of the next element to be scanned.
  90.    This is used for communication to and from the caller
  91.    and for communication between successive calls to `getopt'.
  92.  
  93.    On entry to `getopt', zero means this is the first call; initialize.
  94.  
  95.    When `getopt' returns EOF, this is the index of the first of the
  96.    non-option elements that the caller should itself scan.
  97.  
  98.    Otherwise, `optind' communicates from one call to the next
  99.    how much of ARGV has been scanned so far.  */
  100.  
  101. /* XXX 1003.2 says this must be 1 before any call.  */
  102. int optind = 0;
  103.  
  104. /* The next char to be scanned in the option-element
  105.    in which the last option character we returned was found.
  106.    This allows us to pick up the scan where we left off.
  107.  
  108.    If this is zero, or a null string, it means resume the scan
  109.    by advancing to the next ARGV-element.  */
  110.  
  111. static char *nextchar;
  112.  
  113. /* Callers store zero here to inhibit the error message
  114.    for unrecognized options.  */
  115.  
  116. int opterr = 1;
  117.  
  118. /* Set to an option character which was unrecognized.
  119.    This must be initialized on some systems to avoid linking in the
  120.    system's own getopt implementation.  */
  121.  
  122. int optopt = '?';
  123.  
  124. /* Describe how to deal with options that follow non-option ARGV-elements.
  125.  
  126.    If the caller did not specify anything,
  127.    the default is REQUIRE_ORDER if the environment variable
  128.    POSIXLY_CORRECT is defined, PERMUTE otherwise.
  129.  
  130.    REQUIRE_ORDER means don't recognize them as options;
  131.    stop option processing when the first non-option is seen.
  132.    This is what Unix does.
  133.    This mode of operation is selected by either setting the environment
  134.    variable POSIXLY_CORRECT, or using `+' as the first character
  135.    of the list of option characters.
  136.  
  137.    PERMUTE is the default.  We permute the contents of ARGV as we scan,
  138.    so that eventually all the non-options are at the end.  This allows options
  139.    to be given in any order, even with programs that were not written to
  140.    expect this.
  141.  
  142.    RETURN_IN_ORDER is an option available to programs that were written
  143.    to expect options and other ARGV-elements in any order and that care about
  144.    the ordering of the two.  We describe each non-option ARGV-element
  145.    as if it were the argument of an option with character code 1.
  146.    Using `-' as the first character of the list of option characters
  147.    selects this mode of operation.
  148.  
  149.    The special argument `--' forces an end of option-scanning regardless
  150.    of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
  151.    `--' can cause `getopt' to return EOF with `optind' != ARGC.  */
  152.  
  153. static enum
  154. {
  155.   REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
  156. } ordering;
  157.  
  158. #ifdef    __GNU_LIBRARY__
  159. /* We want to avoid inclusion of string.h with non-GNU libraries
  160.    because there are many ways it can cause trouble.
  161.    On some systems, it contains special magic macros that don't work
  162.    in GCC.  */
  163. #include <string.h>
  164. #define    my_index    strchr
  165. #else
  166.  
  167. /* Avoid depending on library functions or files
  168.    whose names are inconsistent.  */
  169.  
  170. char *getenv ();
  171.  
  172. static char *
  173. my_index (str, chr)
  174.      const char *str;
  175.      int chr;
  176. {
  177.   while (*str)
  178.     {
  179.       if (*str == chr)
  180.     return (char *) str;
  181.       str++;
  182.     }
  183.   return 0;
  184. }
  185.  
  186. /* If using GCC, we can safely declare strlen this way.
  187.    If not using GCC, it is ok not to declare it.
  188.    (Supposedly there are some machines where it might get a warning,
  189.    but changing this conditional to __STDC__ is too risky.)  */
  190. #ifdef __GNUC__
  191. #ifdef IN_GCC
  192. #include "gstddef.h"
  193. #else
  194. #include <stddef.h>
  195. #endif
  196. extern size_t strlen (const char *);
  197. #endif
  198.  
  199. #endif                /* GNU C library.  */
  200.  
  201. /* Handle permutation of arguments.  */
  202.  
  203. /* Describe the part of ARGV that contains non-options that have
  204.    been skipped.  `first_nonopt' is the index in ARGV of the first of them;
  205.    `last_nonopt' is the index after the last of them.  */
  206.  
  207. static int first_nonopt;
  208. static int last_nonopt;
  209.  
  210. /* Exchange two adjacent subsequences of ARGV.
  211.    One subsequence is elements [first_nonopt,last_nonopt)
  212.    which contains all the non-options that have been skipped so far.
  213.    The other is elements [last_nonopt,optind), which contains all
  214.    the options processed since those non-options were skipped.
  215.  
  216.    `first_nonopt' and `last_nonopt' are relocated so that they describe
  217.    the new indices of the non-options in ARGV after they are moved.  */
  218.  
  219. static void
  220. exchange (argv)
  221.      char **argv;
  222. {
  223. /* lines of code deleted */
  224. }
  225.  
  226. /* Scan elements of ARGV (whose length is ARGC) for option characters
  227.    given in OPTSTRING.
  228.  
  229.    If an element of ARGV starts with '-', and is not exactly "-" or "--",
  230.    then it is an option element.  The characters of this element
  231.    (aside from the initial '-') are option characters.  If `getopt'
  232.    is called repeatedly, it returns successively each of the option characters
  233.    from each of the option elements.
  234.  
  235.    If `getopt' finds another option character, it returns that character,
  236.    updating `optind' and `nextchar' so that the next call to `getopt' can
  237.    resume the scan with the following option character or ARGV-element.
  238.  
  239.    If there are no more option characters, `getopt' returns `EOF'.
  240.    Then `optind' is the index in ARGV of the first ARGV-element
  241.    that is not an option.  (The ARGV-elements have been permuted
  242.    so that those that are not options now come last.)
  243.  
  244.    OPTSTRING is a string containing the legitimate option characters.
  245.    If an option character is seen that is not listed in OPTSTRING,
  246.    return '?' after printing an error message.  If you set `opterr' to
  247.    zero, the error message is suppressed but we still return '?'.
  248.  
  249.    If a char in OPTSTRING is followed by a colon, that means it wants an arg,
  250.    so the following text in the same ARGV-element, or the text of the following
  251.    ARGV-element, is returned in `optarg'.  Two colons mean an option that
  252.    wants an optional arg; if there is text in the current ARGV-element,
  253.    it is returned in `optarg', otherwise `optarg' is set to zero.
  254.  
  255.    If OPTSTRING starts with `-' or `+', it requests different methods of
  256.    handling the non-option ARGV-elements.
  257.    See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
  258.  
  259.    Long-named options begin with `--' instead of `-'.
  260.    Their names may be abbreviated as long as the abbreviation is unique
  261.    or is an exact match for some defined option.  If they have an
  262.    argument, it follows the option name in the same ARGV-element, separated
  263.    from the option name by a `=', or else the in next ARGV-element.
  264.    When `getopt' finds a long-named option, it returns 0 if that option's
  265.    `flag' field is nonzero, the value of the option's `val' field
  266.    if the `flag' field is zero.
  267.  
  268.    The elements of ARGV aren't really const, because we permute them.
  269.    But we pretend they're const in the prototype to be compatible
  270.    with other systems.
  271.  
  272.    LONGOPTS is a vector of `struct option' terminated by an
  273.    element containing a name which is zero.
  274.  
  275.    LONGIND returns the index in LONGOPT of the long-named option found.
  276.    It is only valid when a long-named option has been found by the most
  277.    recent call.
  278.  
  279.    If LONG_ONLY is nonzero, '-' as well as '--' can introduce
  280.    long-named options.  */
  281.  
  282. int
  283. _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
  284.      int argc;
  285.      char *const *argv;
  286.      const char *optstring;
  287.      const struct option *longopts;
  288.      int *longind;
  289.      int long_only;
  290. {
  291.   int option_index;
  292. /* many lines of code deleted */
  293. }
  294.  
  295. int
  296. getopt (argc, argv, optstring)
  297.      int argc;
  298.      char *const *argv;
  299.      const char *optstring;
  300. { /* CLASH */
  301.   return _getopt_internal (argc, argv, optstring,
  302.                (const struct option *) 0,
  303.                (int *) 0,
  304.                0);
  305. }
  306.  
  307. #endif    /* _LIBC or not __GNU_LIBRARY__.  */